<?php namespace Home\Model;
use Hdphp\Model\Model;
use Hdphp\Cart;
//我的订单 模型
class Orders extends Model{
//	指定表名
	protected $table = 'orders';
//	自动完成
	protected $auto = array(
	array('number','number','method',3,3),
	array('time','time','function',3,1),
	array('totalprice','total','method',3,1)
	);
//	总计
	public function total(){
		$totaldata = cart::getAllData();
		return $totaldata['total'];
	}
//	订单号
	public function number(){
		$number = Cart::getOrderId();
		return $number;
	}
//	添加订单表
	public function store($adid,$uid,$number){
//		if(!$this->create()) return false;
//		1、查询收货地址
		$addressData = Db::table('address')->where("adid={$adid} AND user_app_uid")->first();
//		sp($addressData);
//		2、组合添加数组
		$totaldata = cart::getAllData();
		$data = array();
		$data['number'] = $number;
		$data['totalprice'] = $totaldata['total'];
		$data['time'] = time();
		$data['name'] = $addressData['uname'];
		$data['address'] = $addressData['address'];
		$data['phone'] = $addressData['phone'];
		$data['status'] = '未支付';
		$data['user_app_uid'] = $uid;
		$oid = $this->add($data);
		return $oid;
	}
}



 ?>